<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <h2>一、是什么</h2>
  <div>正则表达式是一种用来匹配字符串的强有力的武器</div>
  <h4>在 JavaScript中，正则表达式也是对象，构建正则表达式有两种方式：</h4>
  <ul>
    <li>1.字面量创建，其由包含在斜杠之间的模式组成</li>
    <li>2.调用RegExp对象的构造函数</li>
  </ul>
  <script>
    // 1.
    // const re = /\d+/g;
    // console.log(re);
    // 2.
    const re = new RegExp("\\d+","g");
    const rul = "\\d+"
    const re1 = new RegExp(rul,"g");
  </script>
</body>
</html>